package com.schoolhelper.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;


public class MyCache {

    public static String TmpFileName = "SchoolHelperContextSp.tmp";

    public static void write(Context context, String key, String value){
        // 创建的缓存文件
        SharedPreferences mContextSp = context.getSharedPreferences(TmpFileName, Context.MODE_PRIVATE);
        @SuppressLint("CommitPrefEdits") SharedPreferences.Editor editor = mContextSp.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public static String  read(Context context, String key){
        SharedPreferences mContextSp = context.getSharedPreferences(TmpFileName, Context.MODE_PRIVATE);
        return mContextSp.getString(key, null);
    }

}
